home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / magic5.c < prev    next >
C/C++ Source or Header  |  1995-06-21  |  18KB  |  732 lines

  1. /*
  2.  * MAGIC5.C:
  3.  *
  4.  *    Additional spell-casting routines.
  5.  *
  6.  *    Copyright (C) 1991, 1992, 1993 Brett J. Vickers
  7.  *
  8.  */
  9.  
  10. #include "mstruct.h"
  11. #include "mextern.h"
  12.  
  13. /**********************************************************************/
  14. /*                recall                      */
  15. /**********************************************************************/
  16.  
  17. /* This function allows a player to teleport himself or another player */
  18. /* to room #1 (Town Square)                           */
  19.  
  20. int recall(ply_ptr, cmnd, how)
  21. creature    *ply_ptr;
  22. cmd        *cmnd;
  23. int        how;
  24. {
  25.     creature    *crt_ptr;
  26.     room        *rom_ptr, *new_rom;
  27.     int        fd;
  28.  
  29.     fd = ply_ptr->fd;
  30.     rom_ptr = ply_ptr->parent_rom;
  31.  
  32.     if(ply_ptr->mpcur < 25 && how == CAST) {
  33.         print(fd, "Not enough magic points.\n");
  34.         return(0);
  35.     }
  36.  
  37.     if(ply_ptr->class != CLERIC && 
  38.        ply_ptr->class < CARETAKER && how == CAST) {
  39.         print(fd, "Only clerics may cast that spell.\n");
  40.         return(0);
  41.     }
  42.  
  43.     if(!S_ISSET(ply_ptr, SRECAL) && how == CAST) {
  44.         print(fd, "You don't know that spell.\n");
  45.         return(0);
  46.     }
  47.  
  48.     /* Cast recall on self */
  49.     if(cmnd->num == 2) {
  50.  
  51.         if(how == CAST)
  52.             ply_ptr->mpcur -= 25;
  53.  
  54.         if(how == CAST || how == SCROLL || how == WAND) {
  55.             print(fd, "Word of recall spell cast.\n");
  56.             broadcast_rom(fd, ply_ptr->rom_num, 
  57.                       "%M casts word of recall on %sself.", 
  58.                       ply_ptr,
  59.                       F_ISSET(ply_ptr, PMALES) ? "him":"her");
  60.         }
  61.         else if(how == POTION) {
  62.             print(fd, "You phase in and out of existence.\n");
  63.             broadcast_rom(fd, ply_ptr->rom_num,
  64.                 "%M disappears.", ply_ptr);
  65.         }
  66.  
  67.         if(load_rom(1, &new_rom) < 0) {
  68.             print(fd, "Spell failure.\n");
  69.             return(0);
  70.         }
  71.  
  72.         del_ply_rom(ply_ptr, rom_ptr);
  73.         add_ply_rom(ply_ptr, new_rom);
  74.  
  75.         return(1);
  76.     }
  77.  
  78.     /* Cast word of recall on another player */
  79.     else {
  80.  
  81.         if(how == POTION) {
  82.             print(fd, "You can only use a potion on yourself.\n");
  83.             return(0);
  84.         }
  85.  
  86.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  87.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  88.                    cmnd->str[2], cmnd->val[2]);
  89.  
  90.         if(!crt_ptr) {
  91.             print(fd, "That player is not here.\n");
  92.             return(0);
  93.         }
  94.  
  95.         if(how == CAST)
  96.             ply_ptr->mpcur -= 25;
  97.  
  98.         if(how == CAST || how == SCROLL || how == WAND) {
  99.             print(fd, "Word of recall cast on %m.\n", crt_ptr);
  100.             print(crt_ptr->fd, 
  101.                   "%M casts a word of recall spell on you.\n",
  102.                   ply_ptr);
  103.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  104.                        "%M casts word of recall on %m.",
  105.                        ply_ptr, crt_ptr);
  106.  
  107.             if(load_rom(1, &new_rom) < 0) {
  108.                 print(fd, "Spell failure.\n");
  109.                 return(0);
  110.             }
  111.  
  112.             del_ply_rom(crt_ptr, rom_ptr);
  113.             add_ply_rom(crt_ptr, new_rom);
  114.  
  115.             return(1);
  116.         }
  117.     }
  118.  
  119.     return(1);
  120.  
  121. }
  122.  
  123. /**********************************************************************/
  124. /*                summon                      */
  125. /**********************************************************************/
  126.  
  127. /* This function allows players to cast summon spells on anyone who is */
  128. /* in the game, taking that person to your current room.           */
  129.  
  130. int summon(ply_ptr, cmnd, how)
  131. creature    *ply_ptr;
  132. cmd        *cmnd;
  133. int        how;
  134. {
  135.     creature    *crt_ptr;
  136.     room        *rom_ptr, *new_rom;
  137.     int        fd, n;
  138.  
  139.     fd = ply_ptr->fd;
  140.     rom_ptr = ply_ptr->parent_rom;
  141.  
  142.     if(ply_ptr->mpcur < 30 && how == CAST) {
  143.         print(fd, "Not enough magic points.\n");
  144.         return(0);
  145.     }
  146.  
  147.     if(!S_ISSET(ply_ptr, SSUMMO) && how == CAST) {
  148.         print(fd, "You don't know that spell.\n");
  149.         return(0);
  150.     }
  151.  
  152.     if(cmnd->num == 2) {
  153.         print(fd, "You may not use that on yourself.\n");
  154.         return(0);
  155.     }
  156.  
  157.     else {
  158.  
  159.         if(how == POTION) {
  160.             print(fd, "You can only use a potion on yourself.\n");
  161.             return(0);
  162.         }
  163.  
  164.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  165.         crt_ptr = find_who(cmnd->str[2]);
  166.  
  167.         if(!crt_ptr || crt_ptr == ply_ptr || F_ISSET(crt_ptr, PDMINV)) {
  168.             print(fd, 
  169.                   "That player is not playing (Use full names).\n");
  170.             return(0);
  171.         }
  172.  
  173.         if(how == CAST)
  174.             ply_ptr->mpcur -= 30;
  175.  
  176.         n = count_vis_ply(rom_ptr);
  177.         if(F_ISSET(rom_ptr, RNOTEL) ||
  178.           (F_ISSET(rom_ptr, RONEPL) && n > 0) ||
  179.           (F_ISSET(rom_ptr, RTWOPL) && n > 1) ||
  180.           (F_ISSET(rom_ptr, RTHREE) && n > 2)) {
  181.             print(fd, "The spell fizzles.\n");
  182.             return(0);
  183.         }
  184.  
  185.         if(rom_ptr->lolevel > crt_ptr->level ||
  186.            (crt_ptr->level > rom_ptr->hilevel && rom_ptr->hilevel) ||
  187.            F_ISSET(crt_ptr, PNOSUM)) {
  188.             print(fd, "The spell fizzles.\n");
  189.             return(0);
  190.         }
  191.  
  192.         if(F_ISSET(crt_ptr->parent_rom,RNOLEA))
  193.         {
  194.             print(fd, "Your magic can not locate %s.\n",crt_ptr->name);
  195.             return(0);
  196.         }
  197.  
  198.         if(how == CAST || how == SCROLL || how == WAND) {
  199.             print(fd, "You summon %m.\n", crt_ptr);
  200.             print(crt_ptr->fd, 
  201.                   "%M summons you.\n",
  202.                   ply_ptr);
  203.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  204.                        "%M summons %m.",
  205.                        ply_ptr, crt_ptr);
  206.  
  207.             del_ply_rom(crt_ptr, crt_ptr->parent_rom);
  208.             add_ply_rom(crt_ptr, rom_ptr);
  209.  
  210.             return(1);
  211.         }
  212.     }
  213.  
  214.     return(1);
  215.  
  216. }
  217.  
  218. /**********************************************************************/
  219. /*                heal                      */
  220. /**********************************************************************/
  221.  
  222. /* This function will cause the heal spell to be cast on a player or    */
  223. /* another monster.  It heals all hit points damage but only works 3     */
  224. /* times a day.                                */
  225.  
  226. int heal(ply_ptr, cmnd, how)
  227. creature    *ply_ptr;
  228. cmd        *cmnd;
  229. int        how;
  230. {
  231.     creature    *crt_ptr;
  232.     room        *rom_ptr;
  233.     int        fd, heal;
  234.  
  235.     fd = ply_ptr->fd;
  236.     rom_ptr = ply_ptr->parent_rom;
  237.  
  238.     if(ply_ptr->mpcur < 20 && how == CAST) {
  239.         print(fd, "Not enough magic points.\n");
  240.         return(0);
  241.     }
  242.  
  243.     if(ply_ptr->class != CLERIC && ply_ptr->class != PALADIN &&
  244.        ply_ptr->class < CARETAKER && how == CAST) {
  245.         print(fd, "Only paladins and clerics may cast that spell.\n");
  246.         return(0);
  247.     }
  248.  
  249.     if(!S_ISSET(ply_ptr, SFHEAL) && how == CAST) {
  250.         print(fd, "You don't know that spell.\n");
  251.         return(0);
  252.     }
  253.  
  254.     /* Heal self */
  255.     if(cmnd->num == 2 ) {
  256.  
  257.         if(!dec_daily(&ply_ptr->daily[DL_FHEAL]) && how == CAST &&
  258.            ply_ptr->class < CARETAKER) {
  259.             print(fd, "You have healed enough today.\n");
  260.             return(0);
  261.         }
  262.  
  263.         ply_ptr->hpcur = ply_ptr->hpmax;
  264.  
  265.         if(how == CAST) 
  266.             ply_ptr->mpcur -= 20;
  267.  
  268.         if(how == CAST || how == SCROLL) {
  269.             print(fd, "Heal spell cast.\n");
  270.             broadcast_rom(fd, ply_ptr->rom_num, 
  271.                       "%M casts a heal spell on %sself.", 
  272.                       ply_ptr,
  273.                       F_ISSET(ply_ptr, PMALES) ? "him":"her");
  274.             return(1);
  275.         }
  276.         else {
  277.             print(fd, "You feel incredibly better.\n");
  278.             return(1);
  279.         }
  280.     }
  281.  
  282.     /* Cast heal on another player or monster */
  283.     else {
  284.  
  285.         if(how == POTION) {
  286.             print(fd, "You can only use a potion on yourself.\n");
  287.             return(0);
  288.         }
  289.  
  290.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  291.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  292.                    cmnd->str[2], cmnd->val[2]);
  293.  
  294.         if(!crt_ptr) {
  295.             cmnd->str[2][0] = low(cmnd->str[2][0]);
  296.             crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon,
  297.                        cmnd->str[2], cmnd->val[2]);
  298.  
  299.             if(!crt_ptr) {
  300.                 print(fd, "That person is not here.\n");
  301.                 return(0);
  302.             }
  303.         }
  304.  
  305.         if(!dec_daily(&ply_ptr->daily[DL_FHEAL]) && how == CAST &&
  306.            ply_ptr->class < CARETAKER && ply_ptr->type != MONSTER) {
  307.             print(fd, "You have healed enough today.\n");
  308.             return(0);
  309.         }
  310.  
  311.         crt_ptr->hpcur = crt_ptr->hpmax;
  312.  
  313.         if(how == CAST) 
  314.             ply_ptr->mpcur -= 20;
  315.         if(how == CAST || how == SCROLL || how == WAND) {
  316.             print(fd, "Heal spell cast on %m.\n", crt_ptr);
  317.             print(crt_ptr->fd, "%M casts a heal spell on you.\n",
  318.                   ply_ptr);
  319.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  320.                        "%M casts a heal spell on %m.",
  321.                        ply_ptr, crt_ptr);
  322.             return(1);
  323.         }
  324.     }
  325.  
  326.     return(1);
  327.  
  328. }
  329.  
  330. /**********************************************************************/
  331. /*                track                      */
  332. /**********************************************************************/
  333.  
  334. /* This function allows rangers to cast the track spell which takes them */
  335. /* to any other player in the game.                     */
  336.  
  337. int magictrack(ply_ptr, cmnd, how)
  338. creature    *ply_ptr;
  339. cmd        *cmnd;
  340. int        how;
  341. {
  342.     creature    *crt_ptr;
  343.     room        *rom_ptr, *new_rom;
  344.     int        fd, n;
  345.  
  346.     fd = ply_ptr->fd;
  347.     rom_ptr = ply_ptr->parent_rom;
  348.  
  349.     if(ply_ptr->class != RANGER && ply_ptr->class < CARETAKER &&
  350.        how==CAST) {
  351.         print(fd, "Only rangers may cast that spell.\n");
  352.         return(0);
  353.     }
  354.  
  355.     if(ply_ptr->mpcur < 13 && how == CAST) {
  356.         print(fd, "Not enough magic points.\n");
  357.         return(0);
  358.     }
  359.  
  360.     if(!S_ISSET(ply_ptr, STRACK) && how == CAST) {
  361.         print(fd, "You don't know that spell.\n");
  362.         return(0);
  363.     }
  364.  
  365.     if(cmnd->num == 2) {
  366.         print(fd, "You may not use that on yourself.\n");
  367.         return(0);
  368.     }
  369.  
  370.     else {
  371.  
  372.         if(how == POTION) {
  373.             print(fd, "You can only use a potion on yourself.\n");
  374.             return(0);
  375.         }
  376.  
  377.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  378.         crt_ptr = find_who(cmnd->str[2]);
  379.  
  380.         if(!crt_ptr || crt_ptr == ply_ptr || F_ISSET(crt_ptr, PDMINV)) {
  381.             print(fd, 
  382.                   "That player is not playing (Use full names).\n");
  383.             return(0);
  384.         }
  385.  
  386.         if(crt_ptr->class >= CARETAKER) {
  387.             print(fd, "You may not track that player.\n");
  388.             return(0);
  389.         }
  390.  
  391.         n = count_vis_ply(crt_ptr->parent_rom);
  392.         if(F_ISSET(crt_ptr->parent_rom, RNOTEL) ||
  393.           (F_ISSET(crt_ptr->parent_rom, RONEPL) && n > 0) ||
  394.           (F_ISSET(crt_ptr->parent_rom, RTWOPL) && n > 1) ||
  395.           (F_ISSET(crt_ptr->parent_rom, RTHREE) && n > 2)) {
  396.             print(fd, "The spell fizzles.\n");
  397.             return(0);
  398.         }
  399.  
  400.         if(crt_ptr->parent_rom->lolevel > ply_ptr->level ||
  401.            (ply_ptr->level > crt_ptr->parent_rom->hilevel &&
  402.            crt_ptr->parent_rom->hilevel)) {
  403.             print(fd, "The spell fizzles.\n");
  404.             return(0);
  405.         }
  406.  
  407.         if(!dec_daily(&ply_ptr->daily[DL_TRACK]) && how == CAST &&
  408.            ply_ptr->class < CARETAKER) {
  409.             print(fd, "You have tracked enough today.\n");
  410.             return(0);
  411.         }
  412.  
  413.         if(how == CAST)
  414.             ply_ptr->mpcur -= 13;
  415.  
  416.         if(how == CAST || how == SCROLL || how == WAND) {
  417.             print(fd, "You track %m.\n", crt_ptr);
  418.             print(crt_ptr->fd, 
  419.                   "%M has tracked you.\n", ply_ptr);
  420.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  421.                        "%M tracks %m.", ply_ptr, crt_ptr);
  422.  
  423.             del_ply_rom(ply_ptr, rom_ptr);
  424.             add_ply_rom(ply_ptr, crt_ptr->parent_rom);
  425.  
  426.             return(1);
  427.         }
  428.     }
  429.  
  430.     return(1);
  431.  
  432. }
  433.  
  434. /**********************************************************************/
  435. /*                levitate                  */
  436. /**********************************************************************/
  437.  
  438. /* This function allows players to cast the levitate spell, thus allowing */
  439. /* them to levitate over traps or up mountain cliffs.              */
  440.  
  441. int levitate(ply_ptr, cmnd, how)
  442. creature    *ply_ptr;
  443. cmd        *cmnd;
  444. int        how;
  445. {
  446.     creature    *crt_ptr;
  447.     room        *rom_ptr, *new_rom;
  448.     int        fd;
  449.  
  450.     fd = ply_ptr->fd;
  451.     rom_ptr = ply_ptr->parent_rom;
  452.  
  453.     if(ply_ptr->mpcur < 10 && how == CAST) {
  454.         print(fd, "Not enough magic points.\n");
  455.         return(0);
  456.     }
  457.  
  458.     if(!S_ISSET(ply_ptr, SLEVIT) && how == CAST) {
  459.         print(fd, "You don't know that spell.\n");
  460.         return(0);
  461.     }
  462.     if(spell_fail(ply_ptr)) {
  463.                 if(how == CAST)
  464.                      ply_ptr->mpcur -= 10;
  465.                 return(0);
  466.         }
  467.  
  468.     if(cmnd->num == 2) {
  469.         ply_ptr->lasttime[LT_LEVIT].ltime = time(0);
  470.         F_SET(ply_ptr, PLEVIT);
  471.         broadcast_rom(fd, ply_ptr->rom_num, 
  472.             "%M levitates off the floor.", ply_ptr);
  473.         if(how == CAST) {
  474.             print(fd, "You cast a levitation spell.\n");
  475.             ply_ptr->mpcur -= 10;
  476.             ply_ptr->lasttime[LT_LEVIT].interval = 2400L +
  477.                 bonus[ply_ptr->intelligence]*600L;
  478. if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  479.             print(fd,"The room's magical properties increase the power of your spell.\n");
  480.             ply_ptr->lasttime[LT_LEVIT].interval += 800L;
  481.         }                                
  482.         }
  483.         else {
  484.             print(fd, "You begin to float.\n");
  485.             ply_ptr->lasttime[LT_LEVIT].interval = 1200L;
  486.         }
  487.         return(1);
  488.     }
  489.     else {
  490.  
  491.         if(how == POTION) {
  492.             print(fd, "You can only use a potion on yourself.\n");
  493.             return(0);
  494.         }
  495.  
  496.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  497.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  498.                    cmnd->str[2], cmnd->val[2]);
  499.         if(!crt_ptr) {
  500.             print(fd, "I don't see that player here.\n");
  501.             return(0);
  502.         }
  503.  
  504.         F_SET(crt_ptr, PLEVIT);
  505.         crt_ptr->lasttime[LT_LEVIT].ltime = time(0);
  506.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  507.             "%M casts a levitate spell on %m.", ply_ptr, crt_ptr);
  508.         print(crt_ptr->fd, "%M casts levitate on you.\n", ply_ptr);
  509.  
  510.         if(how == CAST) {
  511.             print(fd, "You cast a levitate spell on %s.\n",crt_ptr);
  512.             ply_ptr->mpcur -= 10;
  513.             crt_ptr->lasttime[LT_LEVIT].interval = 2400L +
  514.                 bonus[ply_ptr->intelligence]*600L;
  515.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  516.                   print(fd,"The room's magical properties increase the power of your spell.\n");
  517.                   crt_ptr->lasttime[LT_LEVIT].interval += 800L;
  518.             }                                
  519.         }
  520.  
  521.         else {
  522.             print(fd, "%M begins to float.\n", crt_ptr);
  523.             crt_ptr->lasttime[LT_LEVIT].interval = 1200L;
  524.         }
  525.  
  526.         return(1);
  527.     }
  528.  
  529. }
  530.  
  531. /************************************************************************/
  532. /*                resist_fire                */
  533. /************************************************************************/
  534.  
  535. /* This function allows players to cast the resist fire spell.  It will    */
  536. /* allow the player to resist fire breathed on them by dragons and     */
  537. /* other breathers.                            */
  538.  
  539. int resist_fire(ply_ptr, cmnd, how)
  540. creature    *ply_ptr;
  541. cmd        *cmnd;
  542. int        how;
  543. {
  544.     creature    *crt_ptr;
  545.     room        *rom_ptr, *new_rom;
  546.     int        fd;
  547.  
  548.     fd = ply_ptr->fd;
  549.     rom_ptr = ply_ptr->parent_rom;
  550.  
  551.     if(ply_ptr->mpcur < 12 && how == CAST) {
  552.         print(fd, "Not enough magic points.\n");
  553.         return(0);
  554.     }
  555.  
  556.     if(!S_ISSET(ply_ptr, SRFIRE) && how == CAST) {
  557.         print(fd, "You don't know that spell.\n");
  558.         return(0);
  559.     }
  560.     if(spell_fail(ply_ptr)) {
  561.                 if(how == CAST)
  562.                      ply_ptr->mpcur -= 12;
  563.                 return(0);
  564.         }
  565.  
  566.     if(cmnd->num == 2) {
  567.         ply_ptr->lasttime[LT_RFIRE].ltime = time(0);
  568.         F_SET(ply_ptr, PRFIRE);
  569.         broadcast_rom(fd, ply_ptr->rom_num, 
  570.             "%M resists fire.", ply_ptr);
  571.         if(how == CAST) {
  572.             print(fd, "You cast a resist-fire spell.\nYour skin toughens.\n");
  573.             ply_ptr->mpcur -= 12;
  574.             ply_ptr->lasttime[LT_RFIRE].interval = MAX(300, 1200 +
  575.                 bonus[ply_ptr->intelligence]*600);
  576.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  577.                   print(fd,"The room's magical properties increase the power of your spell.\n");
  578.                   ply_ptr->lasttime[LT_RFIRE].interval += 800L;
  579.             }                                
  580.         }
  581.         else {
  582.             print(fd, "You feel your skin toughen.\n");
  583.             ply_ptr->lasttime[LT_RFIRE].interval = 1200L;
  584.         }
  585.         return(1);
  586.     }
  587.     else {
  588.  
  589.         if(how == POTION) {
  590.             print(fd, "You can only use a potion on yourself.\n");
  591.             return(0);
  592.         }
  593.  
  594.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  595.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  596.                    cmnd->str[2], cmnd->val[2]);
  597.         if(!crt_ptr) {
  598.             print(fd, "I don't see that player here.\n");
  599.             return(0);
  600.         }
  601.  
  602.         F_SET(crt_ptr, PRFIRE);
  603.         crt_ptr->lasttime[LT_RFIRE].ltime = time(0);
  604.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  605.             "%M casts a resist-fire spell on %m.", 
  606.             ply_ptr, crt_ptr);
  607.         print(crt_ptr->fd, "%M casts resist-fire on you.\n", ply_ptr);
  608.  
  609.         if(how == CAST) {
  610.             print(fd, "You cast a resist-fire spell on %s.\n",
  611.                 crt_ptr);
  612.             ply_ptr->mpcur -= 12;
  613.             crt_ptr->lasttime[LT_RFIRE].interval = MAX(300, 1200 +
  614.                 bonus[ply_ptr->intelligence]*600);
  615.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  616.                   print(fd,"The room's magical properties increase the power of your spell.\n");
  617.                   crt_ptr->lasttime[LT_RFIRE].interval += 800L;
  618.             }                                
  619.         }
  620.  
  621.         else {
  622.             print(fd, "%M resists fire.\n", crt_ptr);
  623.             crt_ptr->lasttime[LT_RFIRE].interval = 1200L;
  624.         }
  625.  
  626.         return(1);
  627.     }
  628.  
  629. }
  630.  
  631.  
  632. /************************************************************************/
  633. /*                fly                    */
  634. /************************************************************************/
  635.  
  636. /* This function allows players to cast the fly spell.  It will        */
  637. /* allow the player to fly to areas that are otherwise unreachable    */
  638. /* by foot.                                */
  639.  
  640. int fly(ply_ptr, cmnd, how)
  641. creature    *ply_ptr;
  642. cmd        *cmnd;
  643. int        how;
  644. {
  645.     creature    *crt_ptr;
  646.     room        *rom_ptr;
  647.     int        fd;
  648.  
  649.     fd = ply_ptr->fd;
  650.     rom_ptr = ply_ptr->parent_rom;
  651.  
  652.     if(ply_ptr->mpcur < 15 && how == CAST) {
  653.         print(fd, "Not enough magic points.\n");
  654.         return(0);
  655.     }
  656.  
  657.     if(!S_ISSET(ply_ptr, SFLYSP) && how == CAST) {
  658.         print(fd, "You don't know that spell.\n");
  659.         return(0);
  660.     }
  661.     if(spell_fail(ply_ptr)) {
  662.                 if(how == CAST)
  663.                      ply_ptr->mpcur -= 15;
  664.                 return(0);
  665.         }
  666.  
  667.     if(cmnd->num == 2) {
  668.         ply_ptr->lasttime[LT_FLYSP].ltime = time(0);
  669.         F_SET(ply_ptr, PFLYSP);
  670.         broadcast_rom(fd, ply_ptr->rom_num, 
  671.             "%M begins to fly.", ply_ptr);
  672.         if(how == CAST) {
  673.             print(fd, "You can fly!\n");
  674.             ply_ptr->mpcur -= 15;
  675.             ply_ptr->lasttime[LT_FLYSP].interval = MAX(300, 1200 +
  676.                 bonus[ply_ptr->intelligence]*600);
  677.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  678.                   print(fd,"The room's magical properties increase the power of your spell.\n");
  679.                   ply_ptr->lasttime[LT_FLYSP].interval += 600L;
  680.             }                                
  681.         }
  682.         else {
  683.             print(fd, "You can fly!\n");
  684.             ply_ptr->lasttime[LT_FLYSP].interval = 1200L;
  685.         }
  686.         return(1);
  687.     }
  688.     else {
  689.  
  690.         if(how == POTION) {
  691.             print(fd, "You can only use a potion on yourself.\n");
  692.             return(0);
  693.         }
  694.  
  695.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  696.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  697.                    cmnd->str[2], cmnd->val[2]);
  698.         if(!crt_ptr) {
  699.             print(fd, "I don't see that player here.\n");
  700.             return(0);
  701.         }
  702.  
  703.         F_SET(crt_ptr, PFLYSP);
  704.         crt_ptr->lasttime[LT_FLYSP].ltime = time(0);
  705.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  706.             "%M casts a fly spell on %m.", 
  707.             ply_ptr, crt_ptr);
  708.         print(crt_ptr->fd, "%M casts fly on you.\n", ply_ptr);
  709.  
  710.         if(how == CAST) {
  711.             print(fd, "You cast a fly spell on %s.\n",
  712.                 crt_ptr);
  713.             ply_ptr->mpcur -= 15;
  714.             crt_ptr->lasttime[LT_FLYSP].interval = MAX(300, 1200 +
  715.                 bonus[ply_ptr->intelligence]*600);
  716.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  717.                   print(fd,"The room's magical properties increase the power of your spell.\n");
  718.                   crt_ptr->lasttime[LT_FLYSP].interval += 600L;
  719.             }                                
  720.         }
  721.  
  722.         else {
  723.             print(fd, "%M can fly.\n", crt_ptr);
  724.             crt_ptr->lasttime[LT_FLYSP].interval = 1200L;
  725.         }
  726.  
  727.         return(1);
  728.     }
  729.  
  730. }
  731.  
  732.